<html>
<head>
<script type="text/javascript">

setTimeout(function() { cleanup(); }, 12000);

function out_of_scope_gc_flush() {
  return new Promise(resolve => setTimeout(() => {
    // Let's ensure buffer is garbage collected
    try { new ArrayBuffer(0x80000000); } catch(e) {}

    // Flush.
    navigator.gpu.requestAdapter().then(adapter => {
        adapter.requestDevice().then(device => {})
    });

  }, 0));
}

var fuzzervars = {};

function GetVariable(fuzzervars, var_type) { if(fuzzervars[var_type]) { return fuzzervars[var_type]
; } else { return null; }}

function SetVariable(fuzzervars, var_name, var_type) { fuzzervars[var_type] = var_name; }

function cleanup() {
    try { gc(); } catch(e) {}
    try { new ArrayBuffer(0x80000000); } catch(e) {}
    try { new ArrayBuffer(0x80000000); } catch(e) {}
    try { new ArrayBuffer(0x80000000); } catch(e) {}
    try { new ArrayBuffer(0x80000000); } catch(e) {}

    navigator.gpu.requestAdapter().then(adapter => {
        adapter.requestDevice().then(device => {})
    });
}

async function trigger() {
    const adapter = await navigator.gpu.requestAdapter();
    const device = await adapter.requestDevice();

    const Shader0 = device.createShaderModule({
        code: `
            <shader0>
        `
    });

    const Shader1 = device.createShaderModule({
        code: `
            <shader1>
        `
    });

    const Shader2 = device.createShaderModule({
        code: `
            <shader2>
        `
    });

    const Shader3 = device.createShaderModule({
        code: `
            <shader3>
        `
    });

    const Shader4 = device.createShaderModule({
        code: `
            <shader4>
        `
    });

    const Shader5 = device.createShaderModule({
        code: `
            <shader5>
        `
    });

    const Shader6 = device.createShaderModule({
        code: `
            <shader6>
        `
    });

    const Shader7 = device.createShaderModule({
        code: `
            <shader7>
        `
    });

    const Shader8 = device.createShaderModule({
        code: `
            <shader8>
        `
    });

    const Shader9 = device.createShaderModule({
        code: `
            <shader9>
        `
    });

    <webgpufuzz>

}
</script>

<body onload="trigger()"></body>
</html>